class Solution {
public:
    int uniquePaths(int m, int n) {
        // Start typing your C/C++ solution below
        // DO NOT write int main() function
      vector<vector<int> > dp(n, vector<int>(m));

      dp[0][0] = 1;
      for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
          if (i == 0 && j == 0) {
            continue;
          } else {
            if (i - 1 >= 0) {
              dp[i][j] += dp[i - 1][j];
            }
            if (j - 1 >= 0) {
              dp[i][j] += dp[i][j - 1];
            }
          }
        }
      }
      return dp[n - 1][m - 1];
    }
};
